package com.example.project.webControlleer;

import com.example.project.dao.CarDAO;
import com.example.project.pojo.Car;
import com.example.project.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

@Controller
@RequestMapping("web")
public class WebDeleteCarController {

    @RequestMapping("deletecar")
    public String addcar() {
        return "web/checkcar";
    }

    @RequestMapping("deleteCarName")
    public String deleteCarName(Car car, HttpServletRequest request) {
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String strId = request.getParameter("id");

        CarDAO carDAO = new CarDAO();
        carDAO.deleteById(Integer.parseInt(strId));


        return "";
    }
}



